<?php 
namespace Common\Logic;
use Think\Model;
class UsersLogic extends Model{
	private $m;
	
	function __construct(){
		$this->m = D('UsersDistrictRelation');
	}
	
	//保存教师与课程的关系
	public function _save_relation($uid,$did,$cid){
		$where = array(
				'did' => $did,
				'cid' => $cid,
		);
		$this->m->where($where)->delete();
		foreach ($uid as $u){
			if($u){
				$map=array('uid'=>$u,'did'=>$did,'cid'=>$cid);
				//相同情况
				if(!$this->m->where($map)->find()){
					$this->m->add($map);
				}
			}
		}
	}
	
}
?>